package priv.pront.code.national.acwing.base;

import java.util.Scanner;

public class A2816_判断子序列 {

    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int[] a = new int[n];
        int[] b = new int[m];
        for(int i = 0; i < n; i++) a[i] = scanner.nextInt();
        for(int i = 0; i < m; i++) b[i] = scanner.nextInt();
        int i = 0,j = 0;
        for(; i < n && j < m;){
            if (a[i] == b[j]) {
                i++;
                j++;
            }else{
                j++;
            }
        }
        System.out.println(i == n ? "Yes" : "No");
    }
}
